﻿
function RegTipInfo(o1, msg) {
    document.getElementById(o1).innerHTML = "<img src='../images/reg-info.gif'width=18 height=18 align='absbottom'/> <font color='#ff6600'>" + msg + "</font>";
}

//o1:TextBox;o2:Lable;o3:正则表达式
function RegCheck(o1, o2, o3) {
    if (document.getElementById(o1).value == "") {
        document.getElementById(o2).innerHTML = "<img src='../images/reg-error.gif'width=18 height=18 align='absbottom'/> <font color='#ff0000'>不能为空．</font>";
        return false;
    }
    if (o3 != "") {
        if (!IsValidator(o1, o3)) {
            document.getElementById(o2).innerHTML = "<img src='../images/reg-error.gif'width=18 height=18 align='absbottom'/> <font color='#ff0000'>格式不正确．</font>";
            return false;
        }
    }
    document.getElementById(o2).innerHTML = "<img src='../images/reg-ok.gif'width=18 height=18 align='absbottom'/> <font color='#00ff00'>恭喜输入正确．</font>";
    return true;
}

function IsValidator(o1, o3) {
    var o1Value = document.getElementById(o1).value;
    var patrn = o3;
    if (!patrn.exec(o1Value)) return false;
    return true;
}